home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / doom / quake2.zip / QJOE19.ZIP / MONSTERS.QC < prev    next >
Text File  |  1996-08-14  |  6KB  |  270 lines

  1.     /* ALL MONSTERS SHOULD BE 1 0 0 IN COLOR */
  2.  
  3. // name =[framenum,     nexttime, nextthink] {code}
  4. // expands to:
  5. // name ()
  6. // {
  7. //              self.frame=framenum;
  8. //              self.nextthink = time + nexttime;
  9. //              self.think = nextthink
  10. //              <code>
  11. // };
  12.  
  13.  
  14.  
  15. /*
  16. ================
  17. monster_use
  18.  
  19. Using a monster makes it angry at the current activator
  20. ================
  21. */
  22. void() monster_use =
  23. {
  24.     if (self.enemy)
  25.         return;
  26.     if (self.health <= 0)
  27.         return;
  28.     if (activator.items & IT_INVISIBILITY)
  29.         return;
  30.     if (activator.flags & FL_NOTARGET)
  31.         return;
  32.     if (activator.classname != "player")
  33.         return;
  34.     
  35. // delay reaction so if the monster is teleported, its sound is still
  36. // heard
  37.     self.enemy = activator;
  38.     self.nextthink = time + 0.1;
  39.     self.think = FoundTarget;
  40. };
  41.  
  42. /*
  43. ================
  44. monster_death_use
  45.  
  46. When a mosnter dies, it fires all of its targets with the current
  47. enemy as activator.
  48. ================
  49. */
  50. void() monster_death_use =
  51. {
  52.     local entity    ent, otemp, stemp;
  53.  
  54. // fall to ground
  55.     if (self.flags & FL_FLY)
  56.         self.flags = self.flags - FL_FLY;
  57.     if (self.flags & FL_SWIM)
  58.         self.flags = self.flags - FL_SWIM;
  59.  
  60.     if (!self.target)
  61.         return;
  62.  
  63.     activator = self.enemy;
  64.     SUB_UseTargets ();
  65. };
  66.  
  67.  
  68. //============================================================================
  69.  
  70. void() walkmonster_start_go =
  71. {
  72. local string    stemp;
  73. local entity    etemp;
  74.     
  75.     self.origin_z = self.origin_z + 1;      // raise off floor a bit
  76.     droptofloor();
  77.     
  78.     if (!walkmove(0,0))
  79.     {
  80.         dprint ("walkmonster in wall at: ");
  81.         dprint (vtos(self.origin));
  82.         dprint ("\n");
  83.     }
  84.     
  85.     self.takedamage = DAMAGE_AIM;
  86.  
  87.     self.ideal_yaw = self.angles * '0 1 0';
  88.     if (!self.yaw_speed)
  89.         self.yaw_speed = 20;
  90.     self.view_ofs = '0 0 25';
  91.     self.use = monster_use;
  92.     
  93.     self.flags = self.flags | FL_MONSTER;
  94.     
  95.     if (self.target)
  96.     {
  97.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  98.         self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  99.         if (!self.movetarget)
  100.         {
  101.             dprint ("Monster can't find target at ");
  102.             dprint (vtos(self.origin));
  103.             dprint ("\n");
  104.         }
  105. // this used to be an objerror
  106.         if (self.movetarget.classname == "path_corner")
  107.             self.th_walk ();
  108.         else
  109.             self.pausetime = 99999999;
  110.             self.th_stand ();
  111.     }
  112.     else
  113.     {
  114.         self.pausetime = 99999999;
  115.         self.th_stand ();
  116.     }
  117.  
  118. // spread think times so they don't all happen at same time
  119.     self.nextthink = self.nextthink + random()*0.5;
  120. };
  121.  
  122.  
  123. void() walkmonster_start =
  124. {
  125. // delay drop to floor to make sure all doors have been spawned
  126. // spread think times so they don't all happen at same time
  127.     self.nextthink = self.nextthink + random()*0.5;
  128.     self.think = walkmonster_start_go;
  129.     total_monsters = total_monsters + 1;
  130. };
  131.  
  132.  
  133.  
  134. void() flymonster_start_go =
  135. {
  136.     self.takedamage = DAMAGE_AIM;
  137.  
  138.     self.ideal_yaw = self.angles * '0 1 0';
  139.     if (!self.yaw_speed)
  140.         self.yaw_speed = 10;
  141.     self.view_ofs = '0 0 25';
  142.     self.use = monster_use;
  143.  
  144.     self.flags = self.flags | FL_FLY;
  145.     self.flags = self.flags | FL_MONSTER;
  146.  
  147.     if (!walkmove(0,0))
  148.     {
  149.         dprint ("flymonster in wall at: ");
  150.         dprint (vtos(self.origin));
  151.         dprint ("\n");
  152.     }
  153.  
  154.     if (self.target)
  155.     {
  156.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  157.         if (!self.movetarget)
  158.         {
  159.             dprint ("Monster can't find target at ");
  160.             dprint (vtos(self.origin));
  161.             dprint ("\n");
  162.         }
  163. // this used to be an objerror
  164.         if (self.movetarget.classname == "path_corner")
  165.             self.th_walk ();
  166.         else
  167.             self.pausetime = 99999999;
  168.             self.th_stand ();
  169.     }
  170.     else
  171.     {
  172.         self.pausetime = 99999999;
  173.         self.th_stand ();
  174.     }
  175. };
  176.  
  177. void() flymonster_start =
  178. {
  179. // spread think times so they don't all happen at same time
  180.     self.nextthink = self.nextthink + random()*0.5;
  181.     self.think = flymonster_start_go;
  182.     total_monsters = total_monsters + 1;
  183. };
  184.  
  185.  
  186. void() swimmonster_start_go =
  187. {
  188.     if (deathmatch)
  189.     {
  190.         remove(self);
  191.         return;
  192.     }
  193.  
  194.     self.takedamage = DAMAGE_AIM;
  195.     total_monsters = total_monsters + 1;
  196.  
  197.     self.ideal_yaw = self.angles * '0 1 0';
  198.     if (!self.yaw_speed)
  199.         self.yaw_speed = 10;
  200.     self.view_ofs = '0 0 10';
  201.     self.use = monster_use;
  202.     
  203.     self.flags = self.flags | FL_SWIM;
  204.     self.flags = self.flags | FL_MONSTER;
  205.  
  206.     if (self.target)
  207.     {
  208.         self.goalentity = self.movetarget = find(world, targetname, self.target);
  209.         if (!self.movetarget)
  210.         {
  211.             dprint ("Monster can't find target at ");
  212.             dprint (vtos(self.origin));
  213.             dprint ("\n");
  214.         }
  215. // this used to be an objerror
  216.         self.ideal_yaw = vectoyaw(self.goalentity.origin - self.origin);
  217.         self.th_walk ();
  218.     }
  219.     else
  220.     {
  221.         self.pausetime = 99999999;
  222.         self.th_stand ();
  223.     }
  224.  
  225. // spread think times so they don't all happen at same time
  226.     self.nextthink = self.nextthink + random()*0.5;
  227. };
  228.  
  229. void() swimmonster_start =
  230. {
  231. // spread think times so they don't all happen at same time
  232.     self.nextthink = self.nextthink + random()*0.5;
  233.     self.think = swimmonster_start_go;
  234.     total_monsters = total_monsters + 1;
  235. };
  236.  
  237. // QJOE BELOW
  238.  
  239. void( ) HeadDie =
  240. {
  241.     ThrowGib("progs/gib1.mdl", self.health);
  242.     ThrowGib("progs/gib2.mdl", self.health);
  243.     ThrowGib("progs/gib3.mdl", self.health);
  244.     ThrowHead("progs/gib1.mdl", self.health); //So it doesnt look like head just flew up into air again
  245.     self.solid = SOLID_NOT;
  246.     sound (self, CHAN_VOICE, "player/gib.wav", 1, ATTN_NONE);
  247. };
  248.  
  249. void(string headname, float dm) MakeHead =
  250. {
  251.     setmodel (self, headname);
  252.     self.frame = 0;
  253.     self.nextthink = -1;
  254.     self.movetype = MOVETYPE_STEP;
  255.     self.health = 10;
  256.     self.solid = SOLID_SLIDEBOX;
  257.     self.takedamage = DAMAGE_AIM;
  258.     self.view_ofs = '0 0 8';
  259.     setsize (self, '-16 -16 0', '16 16 56');
  260.     self.velocity = VelocityForDamage (dm);
  261.     self.origin_z = self.origin_z - 24;
  262.     self.avelocity = crandom() * '0 600 0';
  263.     self.classname = "head";
  264.     self.th_die = HeadDie;
  265.     walkmonster_start();
  266.     self.nextthink = self.nextthink + 3; //So they dont getcha right away
  267.     total_monsters = total_monsters - 1;
  268. };
  269.  
  270.